package cn.micro.keep.accounts.api;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private Integer code;
    private String message;
    private T data;

    public Result success(String message,T data){
        return new Result(ResponseEnum.SUCCESS.getCode(), message,data);
    }

    public Result success(T data){
        return new Result(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMessage(), data);
    }

    public Result success(String message){
        return new Result(ResponseEnum.SUCCESS.getCode(), message,null);
    }

    public Result success(){
        return new Result(ResponseEnum.SUCCESS.getCode(),ResponseEnum.SUCCESS.getMessage(),null);
    }

    public Result success(IErrorCode errorCode){
        return new Result(errorCode.getCode(), errorCode.getMessage(),null);
    }

    public Result fail(){
        return new Result(ResponseEnum.FAILED.getCode(), ResponseEnum.FAILED.getMessage(), null);
    }

    public Result fail(String message){
        return new Result(ResponseEnum.FAILED.getCode(), message,null);
    }

    public Result fail(IErrorCode errorCode){
        return new Result(errorCode.getCode(),errorCode.getMessage(),null);
    }

    public Result validateFailed(String message){
        return new Result(ResponseEnum.VALIDATE_FAILED.getCode(), message,null);
    }


}
